//	ID : pallab81
// 	PROG : 439
// 	LANG : C++
// 	2011-07-07-14.08.56 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define mk make_pair
#define f first
#define s second

const int inf = (int)1023456789;
int mov[8][2]={ {-2,+1},{-2,-1},{+2,+1},{+2,-1}, {-1,-2},{+1,-2},{-1,+2},{+1,+2} };
char buff[100],bu1[50],bu2[50];
pair< int , int > source, sink;
int vis[40][40];

inline void split(){
    sscanf(buff,"%s %s",bu1,bu2);
    source.f = bu1[1]-'1';
    source.s = bu1[0]-'a';
    sink.f = bu2[1]-'1';
    sink.s = bu2[0]-'a';
}
inline void ini(){
    for(int i=0;i<40;++i){
        for(int j=0;j<40;++j){
            vis[i][j]= inf;
        }
    }
}
inline void bfs( ){
    ini();
    queue< pair<int,int> > q;
    q.push( mk(source.f,source.s) );
    vis[ source.f ][ source.s ] = 0;

        while( q.empty()==false ){
            pair< int, int > peak = q.front();
            q.pop();

                for(int i=0;i<8;++i){
                    int tr = peak.f+mov[i][0];
                    int tc = peak.s+mov[i][1];
                    if(tr<0||tc<0||tr>=8||tc>=8)continue;
                    if( vis[ peak.f ][ peak.s ]+1 < vis[ tr][tc] ){
                        vis[ tr][tc] = vis[peak.f][peak.s]+1;
                        q.push( mk(tr,tc) );
                    }
                }
        }

        printf("To get from %s to %s takes %d knight moves.\n",bu1,bu2,vis[sink.f][sink.s]);
}

inline void doit(){
    split();
    bfs();
}

int main(){
    while(gets(buff)){
            doit();
    }
return 0;
}

